using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using idea.entity;
using idea.tool;

namespace pos
{
    public partial class ParaClass3Frm : Form
    {
        public ParaClass3Frm()
        {
            InitializeComponent();
        }

        private void cmdAdd_Click(object sender, EventArgs e)
        {
            
            try
            {

                string str = txtClass3.Text.Trim(); ;
                if (str == "")
                    return;
                long id = Convert.ToInt64(cboClass2.SelectedValue);
                if (id < 0)
                    return;
                t_class3 t = new t_class3();
                sequence s = new sequence(t_class3.SEQN0);
                t.seqID = s.getNumberSequence();
                t.name = str;
                t.parentSeqID = id;
                t.add();
                s.UpdateSequence();
                ListViewTool lt = new ListViewTool(listView1);
                t.m_insertRow = lt.insertRow;
                t.ExecDataInsert();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        
        }

        private void ParaClass3Frm_Load(object sender, EventArgs e)
        {
            t_class1 t = new t_class1();
            DataSet set = t.query("", "order by name");

            cboClass1.DropDownStyle = ComboBoxStyle.DropDownList;
            cboClass1.DataSource = set.Tables[0];
            cboClass1.DisplayMember = "name";
            cboClass1.ValueMember = "seqID";

         //   cboClass1.SelectedIndex = 0;


            listView1.Height = this.Height - 100;
            t_class3 t3 = new t_class3();
            ListViewTool lt = new ListViewTool(listView1);
            t3.m_insertHead = lt.insertHead;
            t3.m_insertRow = lt.insertRow;
            t3.ExecDataInsertByQuery("", "", 0);

        }

        private void cboClass1_SelectedIndexChanged(object sender, EventArgs e)
        {

           
        }

        private void cboClass1_SelectedValueChanged(object sender, EventArgs e)
        {
          
        }

        private void cboClass1_SelectionChangeCommitted(object sender, EventArgs e)
        {
             t_class2 t = new t_class2();
            long id = Convert.ToInt64(cboClass1.SelectedValue);
            DataSet set = t.query(string.Format("where parentSeqID={0}", id), "order by name");
            cboClass2.DropDownStyle = ComboBoxStyle.DropDownList;
            cboClass2.DataSource = set.Tables[0];
            cboClass2.DisplayMember = "name";
            cboClass2.ValueMember = "seqID";
            //boClass2.SelectedIndex = 0;
        }
    }
}